<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<title>修改密码</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="../resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form layui-row changePwd" method="post" id="formChange" lay-filter="formChange">
	<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
		<div class="layui-input-block layui-red pwdTips">旧密码请输入“123456”，新密码必须两次输入一致才能提交</div>
		<div class="layui-form-item">
			<label class="layui-form-label">用户名</label>
			<div class="layui-input-block">
				<input type="text" value="" id="name" th:value="${session.username}" disabled  class="layui-input layui-disabled" autocomplete="false">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">旧密码</label>
			<div class="layui-input-block">
				<input type="password" value="" id="oldPassword" placeholder="请输入旧密码" lay-verify="required" class="layui-input pwd" autocomplete="false">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">新密码</label>
			<div class="layui-input-block">
				<input type="password" value="" id="newPwdOne" placeholder="请输入新密码" lay-verify="required|newPwd"  class="layui-input pwd" autocomplete="false">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">确认密码</label>
			<div class="layui-input-block">
				<input type="password" value="" id="newPwdTwo" placeholder="请确认密码" lay-verify="required|confirmPwd" class="layui-input pwd" autocomplete="false">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="changePwd">立即修改</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</div>
</form>
<script type="text/javascript" src="../resources/layui/layui.js"></script>
<script type="text/javascript" src="../resources/page/user/user.js"></script>

<script type="text/javascript">
	layui.use(['jquery','form','layer'],function () {
		var $ = layui.jquery;
		var form = layui.form;
		var layer = layui.layer;


		form.on("submit(changePwd)",function () {
		    var name = $("#name").val();
            var oldPassword = $("#oldPassword").val();
            var newPwdOne = $("#newPwdOne").val();
            var newPwdTwo = $("#newPwdTwo").val();
            layer.confirm('你确定要修改【' + name + '】这个用户的密吗？', {icon: 3, title: '提示'}, function (index) {
				$.post('/user/changePassword',{oldPassword:oldPassword,newPwdOne:newPwdOne,newPwdTwo:newPwdTwo},function (res) {
					layer.msg(res.msg);
				});
				layer.close(index);

            });

        	return false;
		});



    });
</script>

</body>
</html>